/*
* @Author: Yejing
* @Date: 2023-06-30 11:48:33
* @LastEditors: Yejing
* @LastEditTime: 2023-06-30 14:19:39
* @Description: desc
*/
<template>
	<view class="shop-message">
		<!--店鋪头部-->
		<view class="title-block">

			<view class="left" @click="gotoShopDetails()">
				<u-avatar size="112"
					:src='$u.file.getMedieUrl(shopBaseInfo.shopAvatarUrl)'
					:show-level='true'
						:level-icon='cameraFill' 
					mode="circle"></u-avatar>
				<view class="">
					<view class="" style="display: flex; margin-left:16rpx;">
						<view style="
						 				color: #fff;
						 				font-size: 14px;
						 				font-weight: bold;
						 				width: 100px;
						 				display: inline-block;
						 				overflow: hidden;
						 				text-overflow: ellipsis;
						 				white-space: normal;
						 				display: -webkit-box;
						 				-webkit-box-orient: vertical;
						 				-webkit-line-clamp: 1;
						 			">
							{{ shopBaseInfo.shopName }}
						
						</view>
						<view class="" >
							<uni-icons type="forward" size="16" color="#fff"></uni-icons>
						</view>
					</view>
		
					<view class="shopRate">
						
						<u-rate active-color="rgb(253, 161, 22)" inactive-color="#ccc" gutter="3" size="28" :current="shopBaseInfo.mark" :disabled="true"
							style="margin: 0 10rpx;"></u-rate>
						<view class="range">
							{{publicJS.toFixed(shopBaseInfo.mark ) ||0.00}}分
						</view>
					</view>


				</view>
			</view>

			<u-button :loading="isloading" v-if="shopBaseInfo.interest==0" hover-class="none"
				@click="handleClick('/app/shop/interestShop/',$t('classifySeckill.Followed'),1)">{{$t('classifySeckill.Follow')}}
			</u-button>
			<u-button :loading="isloading" v-if="shopBaseInfo.interest==1"
				@click="handleClick('/app/shop/interestShopCancel/',$t('classifySeckill.unfollowed'),0)">{{$t('classifySeckill.Followed')}}
			</u-button>
			
		</view>

	</view>
</template>

<script>
	import { number, string } from "mathjs";

	export default {
		name: "shopsMessage",
		props: {
			shopId: {
				default: 0,
				type: String
			}
		},
		data() {
			return {
				isloading:false,
				//基础信息
				shopBaseInfo: {},
				cameraFill: require('static/images/icon-avator-home.png'),
			};
		},
		created() {
			this.getShopBaseInfo()
		},
		methods: {
			handleClick(url, text, status){
				this.isloading=true
				this.attention(url, text, status)
			},
			getShopBaseInfo() {
				this.$u.get('/app/shop/get/' + this.shopId).then(res => {
					this.shopBaseInfo = res.data
					this.$u.get('/app/shop-level/' + res.data.shopLevelId).then((res) => {
							this.cameraFill = this.$u.file.getMedieUrl(res.data.icon)
						});
				})
			},
			//关注
			attention(url, text, status) {
				this.$u.post(url + this.shopId).then(res => {
					if(res.code==200){
						this.isloading=false
					}
					this.$u.toast(text)
					this.shopBaseInfo.interest = status
				})
			},
			gotoShopDetails(){
				uni.navigateTo({
					url:'/pages/shop/shopDetails?shopId='+this.shopBaseInfo.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.title-block {
		display: flex;
		justify-content: space-between;
		margin-bottom: 48rpx;
		align-items: center;
	/deep/ .u-avatar__level {
			.u-icon__img {
				width: 26px !important;
			}
		}
		.left {
			display: flex;
			color: #FFFFFF;

			.shopRate {
				display: flex;
				align-items: center;
				margin: 10rpx 0;

				.shopRateName {
					color: rgba(95, 100, 140, 1);
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 18rpx;
					width: 100rpx;
					height: 38rpx;
					border-radius: 4rpx;
					border: 1rpx solid rgba(189, 188, 199, 1);
					box-sizing: border-box;
					background: rgba(252, 250, 254, 1);
					line-height: 34rpx;
					text-align: center;
				}
			}

			.info {
				margin-left: 20rpx;
				padding-right: 40rpx;

				.title {
					font-size: 32rpx;
					font-weight: 500;
					color: #FFFFFF;
					line-height: 38rpx;
					margin-bottom: 12rpx;
					display: inline-block;
					width: 170px;
					color: #FFFFFF;
					line-height: 19px;
					margin-bottom: 6px;
					display: inline-block;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: normal;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
				}

				.tag {
					padding: 3rpx 4rpx;
					background: #2934D0;
					border-radius: 6rpx;
					font-size: 22rpx;
					position: relative;
					margin-right: 20rpx;

					&:after {
						position: absolute;
						content: '';
						right: -12rpx;
						width: 2rpx;
						height: 100%;
						background: #fff;
						top: 0;
					}

				}

				.font {
					font-size: 24rpx;
					font-weight: 400;
					color: #999CAD;
					margin-left: 10rpx;
				}


			}
		}

		uni-button {
			margin: 0;
			height: 58rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 48rpx;
			background: rgba(252, 61, 92, 1);
			border-radius: 12rpx;
			padding: 0rpx 20rpx;
		}
	}
</style>